public class OddCells {

    int[][] nums;
    public int oddCells1(int m, int n, int[][] indices) {
        nums = new int[m][n];
        for (int[] index : indices) {
            process(index[0], index[1]);
        }
        int ans = 0;
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                ans += nums[i][j] % 2 != 0 ? 1 : 0;
            }
        }
        return ans;
    }

    public void process(int i, int j) {
        for (int k = 0; k < nums.length; k++) {
            nums[k][j]++;
        }
        for (int k = 0; k < nums[0].length; k++) {
            nums[i][k]++;
        }
    }

    public int oddCells(int m, int n, int[][] indices) {
        int[] row = new int[m];
        int[] col = new int[n];
        for (int[] index : indices) {
            row[index[0]]++;
            col[index[1]]++;
        }
        int ans = 0;
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                if ((row[i] + col[j]) % 2 != 0) ++ans;
            }
        }
        return ans;
    }
}
